package com.sample.plove.database.service.impl;

import com.sample.plove.database.dao.CardTypeRepository;
import com.sample.plove.database.model.CardTypeEntity;
import com.sample.plove.database.service.CardTypeServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * PackageName:com.sample.plove.database.service.impl
 * Author:Administrator
 * Time:21:54
 * Date:2019/5/18
 * Describe:
 */
@Repository
public class CardTypeServerImpl implements CardTypeServer {
    private static final Logger log = LoggerFactory.getLogger("CardTypeServerImpl");
    @Autowired
    CardTypeRepository cardTypeRepository;
    @Override
    public void addCardType(CardTypeEntity entity) {
        log.info("");
        cardTypeRepository.save(entity);
    }

    @Override
    public Optional<CardTypeEntity> findCardTypeById(int id) {
        log.info("");
        return cardTypeRepository.findById(id);
    }

    @Override
    public List<CardTypeEntity> findAllCardType() {
        log.info("");
        return cardTypeRepository.findAll();
    }

    @Override
    public void updateCardType(CardTypeEntity entity) {
        log.info("");
        cardTypeRepository.save(entity);
    }

    @Override
    public void removeCardType(CardTypeEntity entity) {
        log.info("");
        cardTypeRepository.delete(entity);
    }

    @Override
    public void cleanCardType() {
        log.info("");
        cardTypeRepository.deleteAll();
    }
}
